<template>
  <page>
    <div class="Avatar">
      <img class="Avatar-i" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1563863194273&di=d7de421f687fa2d93a7ad4617aac2e89&imgtype=0&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201505%2F28%2F20150528130730_rWnTt.jpeg" alt="" />
    </div>
    <div class="login-wrap">
     <div class="login">

         <input type="text" placeholder="请填写手机号登录/注册" v-model="phone"/>



       </div>

      </div>
    <div class="login-wrap">
      <div class="login">

          <input type="password" placeholder="请填写您密码/注册" v-model="password" />



      </div>
    </div>
    <div class="commit-wrap">
       <button class="commit" @click="handletry">确定</button>
    </div>
  </page>
</template>

<script>

  export default {


    data() {
      return {
        show: true,
          type:'Registered',
          password:'',
          phone:'',



      }
    },
    methods: {

        handletry(){
          // console.log(this.password);
          // console.log(this.global.myID);
          let that=this;
          // let pages = getCurrentPages();
          //
          // let prevPage = pages[ pages.length - 3 ];

          wx.request({
            url: 'http://192.168.1.20:8099/WebHandler/GuoUserHandler.ashx',
            method: 'post',
            data: {
              type: 'Registered',
              password: this.password,
              phone: this.phone
            },
            header: {
              'content-type': 'application/x-www-form-urlencoded' // 默认值
            },
            success: function (res) {
              // that.global.myID=res.data.myuserID;
              // var ll=getCurrentPages()
              // console.log(res)
              if(res.data.msg==='注册成功'){
                that.global.loginflag=false;
                that.global.myID=res.data.yourID;
                that.global.myTel=res.data.yourTel;
                // wx.showToast({
                //   title: res.data.msg,
                //   icon: 'success',
                //   duration: 2000,
                // });
                // setTimeout(function () {
                //   wx.reLaunch({
                //     url: '../counter/index',
                //   })
                // }, 2000)
                wx.showModal({
                  title: '亲，您',
                  content: res.data.msg,
                  success (res) {
                    if (res.confirm) {
                      wx.navigateBack({
                        delta: 2  // 返回上一级页面。
                      })
                    } else if (res.cancel) {
                      console.log('用户点击取消')

                    }
                  }
                })
              }else if(res.data.msg==="登录成功") {
                that.global.loginflag=false;
                that.global.myID=res.data.yourID;
                that.global.myTel=res.data.yourTel;
                wx.showModal({
                  title: '欢迎大佬',
                  content: res.data.msg,
                  success (res) {
                    if (res.confirm) {
                      wx.navigateBack({
                        delta: 2  // 返回上一级页面。
                      })

                    } else if (res.cancel) {
                      console.log('用户点击取消')

                    }
                  }
                })

              }else{
                wx.showToast({
                  title: res.data.msg,
                  icon: 'none',
                  duration: 2000
                })
              }
            }

         });
         // console.log(this.global.myID)
         //  console.log(this.global.loginflag)

        },
      //   ID(){
      //   console.log(this.global.myID)
      //     console.log(this.global.myTel)
      // },
    },


  }
</script>

<style>
page{
  background-color: #fff;
  height: 100%;
}
  .Avatar{
    height: 40%;
    width:100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .Avatar-i{
    height: 400rpx;
    width:400rpx;
    border-radius: 50%;
  }
  .login-wrap{
    height: 100rpx;
    width:100%;
    margin-top:20rpx;
  }
  .login{
    border:1px solid red;
    border-radius: 52rpx;
    height: 100%;
    width:80%;
    margin:0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .commit-wrap{
    height: 100rpx;
    width:100%;
    margin-top:20rpx;
  }
  .commit{
    height: 100%;
    width:30%;
    color:#fff;
    background-color: #49B152;
    margin:0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius:22rpx;
    outline: none;
    border: none;
    cursor: pointer;
    /*color: white;*/
    position: relative;
    padding: 0.5em 1em;
    /*background-color: #40a9ff;*/

  }
button {
  z-index: 1;
  overflow: hidden;
}
button::before {
  z-index: -1;
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background-color: #9254de;
  transform-origin: center;
  transform: translate3d(-50%, -50%, 0) scale(0, 0);
  transition: transform 0.45s ease-in-out;
}

button:hover::before {
  transform: translate3d(-50%, -50%, 0) scale(15, 15);
}
</style>
